home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 98
/
Skunkware 98.iso
/
src
/
mail
/
pine3.96.tar.gz
/
pine3.96.tar
/
pine3.96
/
pine
/
osdep
/
execview
< prev
next >
Wrap
Text File
|
1996-07-15
|
2KB
|
81 lines
/* ----------------------------------------------------------------------
Execute the given mailcap command
Args: cmd -- the command to execute
image_file -- the file the data is in
needsterminal -- does this command want to take over the terminal?
----*/
void
exec_mailcap_cmd(cmd, image_file, needsterminal)
char *cmd;
char *image_file;
int needsterminal;
{
char *command = NULL,
*result_file = NULL,
*p;
char **r_file_h;
PIPE_S *syspipe;
int mode;
p = command = (char *)fs_get((32 + strlen(cmd) + (2*strlen(image_file)))
* sizeof(char));
if(!needsterminal) /* put in background if it doesn't need terminal */
*p++ = '(';
sprintf(p, "%s ; rm -f %s", cmd, image_file);
p += strlen(p);
if(!needsterminal){
*p++ = ')';
*p++ = ' ';
*p++ = '&';
}
*p++ = '\n';
*p = '\0';
dprint(9, (debugfile, "exec_mailcap_cmd: command=%s\n", command));
mode = PIPE_RESET;
if(needsterminal == 1)
r_file_h = NULL;
else{
mode |= PIPE_WRITE | PIPE_STDERR;
result_file = temp_nam(NULL, "pine_cmd");
r_file_h = &result_file;
}
if(syspipe = open_system_pipe(command, r_file_h, NULL, mode)){
close_system_pipe(&syspipe);
if(needsterminal == 1)
q_status_message(SM_ORDER, 0, 4, "VIEWER command completed");
else if(needsterminal == 2)
display_output_file(result_file, "VIEWER", " command result");
else
display_output_file(result_file, "VIEWER", " command launched");
}
else
q_status_message1(SM_ORDER, 3, 4, "Cannot spawn command : %s", cmd);
fs_give((void **)&command);
if(result_file)
fs_give((void **)&result_file);
}
/* ----------------------------------------------------------------------
Execute the given mailcap test= cmd
Args: cmd -- command to execute
Returns exit status
----*/
int
exec_mailcap_test_cmd(cmd)
char *cmd;
{
PIPE_S *syspipe;
return((syspipe = open_system_pipe(cmd, NULL, NULL, PIPE_SILENT))
? close_system_pipe(&syspipe) : -1);
}